﻿@model FO.Models.News
@{
    ViewBag.Title = "Cập nhật - " + Model.NewsTitle + "";
    Layout = "~/Views/Shared/_CpanelLayout.cshtml";
}

<script src="/Content/js/jquery.ui.datepicker.js" type="text/javascript"></script>
<script type="text/javascript" src="@Url.Content("~/ckeditor/ckeditor.js")"></script>
<script type="text/javascript" src="@Url.Content("~/ckeditor/config.js")"></script>
<script type="text/javascript" src="@Url.Content("~/ckfinder/ckfinder.js")"></script>
<script type="text/javascript">
    $(document).ready(function () {
        $(".active").removeClass("active");
        $("li[rel=rel-article]").parent().parent().css("display", "block");
        $("li[rel=rel-article]").parent().parent().prev().addClass("active");
        $("li[rel=rel-article]").addClass("active");
        $("li[rel=rel-article-all]").addClass("active");
        $("#browers-img").click(function () {
            var finder = new CKFinder();
            finder.selectActionFunction = function (fileUrl) {
                $('#NewsImg').val(fileUrl);
                $('#img-news').attr("src", fileUrl)
            };
            finder.popup();
        });
    });
</script>

<script type="text/javascript">
    $(function () {
        $("#NewsDeadline").datepicker({
            dateFormat: "dd/mm/yy",
            changeMonth: true,
            changeYear: true,
            setDate: "" +@Model.NewsDeadline +""
        });
    });
</script>
<div class="cbread_crumb">
    <ul class="breadcrumb">
        <li><a class="glyphicons home" href="/Cpanel"><i></i>Control panel</a></li>
        <li class="divider"></li>
        <li><a href="@Url.Action("ManagerNews","News")">Tin khuyến mãi</a></li>
        <li class="divider"></li>
        <li class="lastli">Cập nhật - @Model.NewsTitle</li>
    </ul>
</div>
<div class="content-module-heading cf">
    <div class="separator"></div>
    <div class="heading-buttons">
        <h3 class="glyphicons notes"><i></i>@Model.NewsTitle</h3>
        <div class="clearfix"></div>
    </div>
    <div class="separator"></div>

</div>
<div class="innerLR">

    @using (Html.BeginForm())
    {
        <div class="well" style="padding-bottom: 20px; margin: 0;">
            @Html.HiddenFor(m => m.NewsID)
            <p style="float: left;">
                <label class="label-text">Tiêu đề (*)</label>
                @Html.TextBoxFor(m => m.NewsTitle, new { @class = "span5" })
            </p>
            <p>@Html.ValidationMessageFor(m => m.NewsTitle, "", new { @style = "color:red;width:585px; float:left;" })</p>
            <div class="clr"></div>
            <div class="clr"></div>
            <p style="float: left; width: 30%; margin-right: 10px;">
                <label class="label-text">Ngân hàng</label>
                @Html.DropDownListFor(m => m.CompanyID, (IEnumerable<SelectListItem>)ViewBag.CompanyListID)
            </p>
            <p style="float: left; width: 30%;">
                <label class="label-text">Sản phẩm</label>
                @Html.DropDownListFor(m => m.ProductID, (IEnumerable<SelectListItem>)ViewBag.ProductListID)
            </p>
            <p style="float: left;" class="span55">
                <label class="label-text">Ngày hết hạn tin</label>
                @Html.TextBoxFor(m => m.NewsDeadline, new { @class = "span5" })
                @Html.ValidationMessageFor(m => m.NewsDeadline, "", new { @class = "label label-important", @style = "float:left; margin-right:38px;" })
            </p>
            <p style="width: 48%; float: left; margin-right: 30px;">
                <label class="label-text">Tóm tắt</label>
                @Html.TextAreaFor(m => m.NewsSumary, new { @class = "span5", style = "height:100px;" })
                @Html.ValidationMessageFor(m => m.NewsSumary, "", new { @style = "color:red;" })
            </p>
            <div class="clr"></div>
            <p style="float: left; width: 30%;">
                <label class="label-text">Hình ảnh</label>
                   @Html.TextBoxFor(m => m.NewsImg, new { @class = "round default-width-input", @readonly = "readonly" })
                <a id="browers-img" class="btn btn-primary" title="Chọn ảnh" href="#">Chọn ảnh</a>
            </p>

            <div class="clr"></div>
            <p>@Html.ValidationMessageFor(m => m.NewsImg, "", new { @style = "color:red;" }) </p>


            <div class="clr"></div>
           
             <img id="img-news" style="margin-top:10px;" width="220" height="130" src="@Model.NewsImg" />
            <p style="width: 100%; float: left; margin-top: 30px;">
                <label class="label-text">Nội dung</label>
                @Html.TextAreaFor(m => m.NewsContent, new { id = "description" })
            </p>
            <p style="width: 100%; float: left;">
                <label class="label-text">Cho phép hiển thị</label>
                @Html.CheckBoxFor(m => m.Enable)
            </p>
            <p style="width: 100%; float: left;">
                <label class="label-text">Tin nổi bật</label>
                @Html.CheckBoxFor(m => m.NewsHot)
            </p>
            <div class="clr"></div>
            <div class="form-actions">
                <button type="submit" class="btn btn-icon btn-primary glyphicons circle_ok"><i></i>Lưu</button>
            </div>
            <p>Người tạo: @Model.CreateUser</p>
            <p>Ngày tạo: @Model.CreateDate</p>
            @if (@Model.UpdateUser != "")
            {
                <p>Cập nhật cuối: @Model.UpdateUser</p>
                <p>Ngày cập nhật: @Model.UpdateDate</p>
            }
            else
            {
                <p>Chưa có cập nhật nào.</p>
            }
        </div>                
    }
</div>
<!-- end content-module-main -->
<script type="text/javascript">
    var ck = CKEDITOR.instances['BlogNewsContent', ''];
    if (ck)//check if instance exist
    {
        CKEDITOR.remove(ck);
    }

    CKEDITOR.replace('NewsContent', {
        autoGrow_maxHeight: 600,
        height: '310px',
        enterMode: CKEDITOR.ENTER_BR,
        filebrowserBrowseUrl: '@Url.Content("~/ckfinder/ckfinder.html")',
        filebrowserImageBrowseUrl: '@Url.Content("~/ckfinder/ckfinder.html?type=Images")',
        filebrowserUploadUrl: '@Url.Content("~/ckfinder/core/connector/aspx/connector.aspx?command=QuickUpload&type=Files")',
        filebrowserImageUploadUrl: '@Url.Content("~/ckfinder/core/connector/aspx/connector.aspx?command=QuickUpload&type=Images")',
        filebrowserWindowWidth: 800,
        filebrowserWindowHeight: 500,
        toolbar:
		   [
	{ name: 'document', groups: ['mode', 'document', 'doctools'], items: ['Source', '-', 'Save', 'NewPage', 'Preview', 'Print', '-', 'Templates'] },
	{ name: 'clipboard', groups: ['clipboard', 'undo'], items: ['Cut', 'Copy', 'Paste', 'PasteText', 'PasteFromWord', '-', 'Undo', 'Redo'] },
	{ name: 'editing', groups: ['find', 'selection', 'spellchecker'], items: ['Find', 'Replace', '-', 'SelectAll', '-', 'Scayt'] },
	{ name: 'forms', items: ['Form', 'Checkbox', 'Radio', 'TextField', 'Textarea', 'Select', 'Button', 'ImageButton', 'HiddenField'] },
	'/',
	{ name: 'basicstyles', groups: ['basicstyles', 'cleanup'], items: ['Bold', 'Italic', 'Underline', 'Strike', 'Subscript', 'Superscript', '-', 'RemoveFormat'] },
	{ name: 'paragraph', groups: ['list', 'indent', 'blocks', 'align', 'bidi'], items: ['NumberedList', 'BulletedList', '-', 'Outdent', 'Indent', '-', 'Blockquote', 'CreateDiv', '-', 'JustifyLeft', 'JustifyCenter', 'JustifyRight', 'JustifyBlock', '-', 'BidiLtr', 'BidiRtl', 'Language'] },
	{ name: 'links', items: ['Link', 'Unlink', 'Anchor'] },
	{ name: 'insert', items: ['Image', 'Flash', 'Table', 'HorizontalRule', 'Smiley', 'SpecialChar', 'PageBreak', 'Iframe'] },
	'/',
	{ name: 'styles', items: ['Styles', 'Format', 'Font', 'FontSize'] },
	{ name: 'colors', items: ['TextColor', 'BGColor'] },
	{ name: 'tools', items: ['Maximize', 'ShowBlocks'] },
	{ name: 'others', items: ['-'] },
	{ name: 'about', items: ['About'] }
		   ],

        // Toolbar groups configuration.
        toolbarGroups: [
            { name: 'document', groups: ['mode', 'document', 'doctools'] },
            { name: 'clipboard', groups: ['clipboard', 'undo'] },
            { name: 'editing', groups: ['find', 'selection', 'spellchecker'] },
            { name: 'forms' },
            '/',
            { name: 'basicstyles', groups: ['basicstyles', 'cleanup'] },
            { name: 'paragraph', groups: ['list', 'indent', 'blocks', 'align', 'bidi'] },
            { name: 'links' },
            { name: 'insert' },
            '/',
            { name: 'styles' },
            { name: 'colors' },
            { name: 'tools' },
            { name: 'others' },
            { name: 'about' }
        ]
    });
</script>



